package com.leet.meituan;

import java.util.Scanner;

public class NumOfE {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n  = Integer.parseInt(sc.nextLine());
        String s = sc.nextLine();
        s.toCharArray();
        int ans = 0;
        int max_num = 0;
        for (int i = 0; i < n; i++){
            if(s.charAt(i) == 'E'){
                ans += 1;
                max_num = Math.max(ans,max_num);
            }else ans -= 1;
            if(ans < 0){
                ans = 0;
            }
        }
        System.out.println(max_num);
    }
}
